package com.ruoyi.system.api;

import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.domain.SysDictData;
import com.ruoyi.system.api.factory.RemoteUserFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 系统字典表服务
 * 
 * @author lcj
 */
@FeignClient(contextId = "remoteSysDictService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteDictService {

    /**
     * 查询数据字典
     *
     * @param dictType 字典类型
     * @return 结果
     */
    @GetMapping("/dict/data/getDictData/{dictType}")
    public R<List<SysDictData>> getDictData(@PathVariable("dictType") String dictType, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 查询字典值详情
     *
     * @param dictType 字典类型
     * @param dictValue 字典值
     * @return 结果
     */
    @GetMapping("/dict/data/getDictLabel")
    public R<String> getDictLabel(@RequestParam("dictType") String dictType,@RequestParam("dictValue")String dictValue, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 查询关联数据库数据
     *
     * @return 结果
     */
    @GetMapping("/dict/data/queryTableDictTextByKey")
    public R<String> queryTableDictTextByKey(@RequestParam("table") String table,@RequestParam("text") String text,
                                             @RequestParam("code") String code, @RequestParam("key") String key,
                                             @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

}
